<script setup lang="ts">
import { ref } from 'vue'
import request from './utils/index'

const list = ref<{ id: number; name: string }[]>([])

// {value}
const btnClick = async () => {
  const res = await request<
    any,
    {
      data: {
        channels: { id: number; name: string }[]
      }
      message: string
    }
  >({
    url: '/v1_0/channels'
  })
  list.value = res.data.channels
  console.log('接口返回值', res.data.channels, list)
}
</script>

<template>
  <button @click="btnClick">调用接口</button>
  <ul>
    <li v-for="item in list" :key="item.id">{{ item.name }}</li>
  </ul>
</template>

<style scoped></style>
